#include <math.h>
#include <qapplication.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qwt_slider.h>
#include <qwt_scale_engine.h>
#include <qwt_scale_map.h>
#include "print_labels.h"
#include "print_labeled_spinbox.h"
#include<QSpinBox>

print_labeled_spinbox::print_labeled_spinbox(QWidget *parent, QString pre_text_in, float single_step_in, int decimal_precision_in, float min_range_in, float max_range_in, float init_value_in):
    QWidget(parent)
{
	
   this->pre_text=pre_text_in;
   this->single_step=single_step_in;
   this->decimal_precision=decimal_precision_in;
   this->min_range=min_range_in;
   this->max_range=max_range_in;
   this->init_value=init_value_in;

   d_label = new QLabel(pre_text, this); //new is for pointers only
   QRect pos_d_label = QRect(0, 0, 6.5*int(pre_text.length()), 20);
   d_label->setGeometry(pos_d_label);

   int text_width = d_label->width();

   my_spin_box = new QDoubleSpinBox(this);  
   QRect pos_my_spin_box = QRect(0+6.5*int(pre_text.length()), 2, 60, 20);   
   my_spin_box->setDecimals(decimal_precision); //this line must be set first so as not to round any of the following parameters!
   my_spin_box->setGeometry(pos_my_spin_box);
   my_spin_box->setSingleStep(single_step);
   my_spin_box->setRange(min_range,max_range);
   my_spin_box->setValue(init_value);
   
}

double print_labeled_spinbox::getValue(void)
{
	return my_spin_box->value();
}
